package com.atguigu.passwordEncoder;

import com.atguigu.util.MD5Utils;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class MyMd5PasswordEncder implements PasswordEncoder {
    //rawPassword 客戶端输入的明文
    @Override
    public String encode(CharSequence rawPassword) {
        return MD5Utils.md5(rawPassword.toString());
    }

    //encodedPassWord 数据库的密文
    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassWord) {
        return encode(rawPassword.toString()).equals(encodedPassWord);
    }
}
